import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_verify/lf_verify_id_confirm/lf_verify_id_confirm_logic.dart';
import 'package:largefriends/res.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:largefriends/widgets/lf_app_bar.dart';

import '../../../config/lf_config.dart';
import '../../../res/lf_fonts.dart';
import '../../../res/lf_text_style.dart';
import '../../../res/strings/lf_strings.dart';
import '../../../widgets/lf_button.dart';
import '../../../widgets/lf_image_picker.dart';
import '../../lf_browser/lf_browser_logic.dart';
import 'lf_verify_id_logic.dart';

class LfVerifyIdPage extends StatefulWidget {
  const LfVerifyIdPage({super.key});

  @override
  State<LfVerifyIdPage> createState() => _LfVerifyIdPageState();
}

class _LfVerifyIdPageState extends State<LfVerifyIdPage> {
  final logic = Get.put(LfVerifyIdLogic());

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: Scaffold(
          appBar: lfAppBar(
            leadingCallback: () {
              Get.back();
            },
            title: strVerifyByID.tr,
          ),
          body: GetBuilder<LfVerifyIdLogic>(
            builder: (controller) {
              return Padding(
                padding: EdgeInsets.symmetric(horizontal: 16.w),
                child: CustomScrollView(
                  physics: const BouncingScrollPhysics(),
                  slivers: [
                    Image.asset(
                      Res.verify_license,
                      fit: BoxFit.contain,
                    ).sliverBox,
                    15.h.sbh.sliverBox,
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Image.asset(
                          Res.verify_fire,
                          fit: BoxFit.cover,
                          height: 22.h,
                        ),
                        8.w.sbw,
                        Expanded(
                          child: Text(
                            strGetMoreViewsAndMessages.tr,
                            style: lfTextStyle(
                              sp: 15.sp,
                              fontFamily: fontRegular,
                            ),
                          ),
                        ),
                      ],
                    ).sliverBox,
                    15.h.sbh.sliverBox,
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Image.asset(
                          Res.verify_lighting,
                          fit: BoxFit.cover,
                          height: 22.h,
                        ),
                        8.w.sbw,
                        Expanded(
                          child: Text(
                            strShowCredibility.tr,
                            style: lfTextStyle(
                              sp: 15.sp,
                              fontFamily: fontRegular,
                            ),
                          ),
                        ),
                      ],
                    ).sliverBox,
                    25.h.sbh.sliverBox,
                    Padding(
                      padding: EdgeInsets.symmetric(horizontal: 8.w),
                      child: LfButton(
                        text: strVerifyNow.tr,
                        onPress: () {
                          LfImagePicker.pickerImage((file) {
                            toVerifyIdConfirm(image: file.first);
                          }, maxCount: 1);
                        },
                        enabled: true,
                      ),
                    ).sliverBox,
                    25.h.sbh.sliverBox,
                    Text(
                      strVerifyIdFirstTip.tr,
                      style: lfTextStyle(
                        sp: 14.sp,
                        fontFamily: fontRegular,
                      ),
                    ).sliverBox,
                    25.h.sbh.sliverBox,
                    Text.rich(
                      TextSpan(
                        text: strVerifyIdSecondTip.tr.split("%%s").first,
                        children: [
                          TextSpan(
                            text: strPrivacyPolicy.tr,
                            style: lfTextStyle(
                              sp: 14.sp,
                              fontFamily: fontRegular,
                              decoration: TextDecoration.underline,
                            ),
                            recognizer: TapGestureRecognizer()
                              ..onTap = () {
                                toBrowserPage(
                                  title: strPrivacyPolicy.tr,
                                  url: "$webUrl$privacyPolicyUrl",
                                );
                              },
                          ),
                          TextSpan(
                            text: strVerifyIdSecondTip.tr.split("%%s").last,
                            style: lfTextStyle(
                              sp: 14.sp,
                              fontFamily: fontRegular,
                            ),
                          ),
                        ],
                      ),
                      style: lfTextStyle(
                        sp: 14.sp,
                        fontFamily: fontRegular,
                      ),
                    ).sliverBox,
                    25.h.sbh.sliverBox,
                    Text(
                      strVerifyIdThirdTip.tr,
                      style: lfTextStyle(
                        sp: 14.sp,
                        fontFamily: fontRegular,
                      ),
                    ).sliverBox,
                    20.h.sliverBox,
                  ],
                ),
              );
            },
          ),
        ),
        onWillPop: () async {
          Get.back();
          return true;
        });
  }
}
